using System;
using System.Collections.Generic;
using System.Text;
using CompositeWeb.Extensions.Interfaces;
using Microsoft.Practices.CompositeWeb.Utility;
using System.Collections.Specialized;

namespace CompositeWeb.Extensions
{
    /// <summary>
    /// Defines the basic metadata needed to describe a service.
    /// </summary>
    public class ServiceInfo
    {
        private Type _registerAs;
        private Type _type;
        private ServiceScope _scope;

        /// <summary>
        /// Initializes a new instance of a <see cref="ServiceInfo"/>.
        /// </summary>
        public ServiceInfo()
        {
        }

        /// <summary>
        /// Initializes a new instance of a <see cref="ServiceInfo"/> with the given values.
        /// </summary>
        /// <param name="registerAs">The contract of the service.</param>
        /// <param name="type">The type of the service.</param>
        public ServiceInfo(Type registerAs, Type type, string scope)
        {
            _registerAs = registerAs;
            _type = type;

            Guard.EnumValueIsDefined(typeof(ServiceScope), scope, "scope");

            _scope = (ServiceScope)Enum.Parse(typeof(ServiceScope), scope);
        }

        /// <summary>
        /// Gets or sets the service contract.
        /// </summary>
        public Type RegisterAs        
        {
            get { return _registerAs; }
            set { _registerAs = value; }
        }

        /// <summary>
        /// Gets or sets the service type
        /// </summary>
        public Type Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public ServiceScope Scope
        {
            get { return _scope; }
            set { _scope = value; }
        }
    }

    public enum ServiceScope
    {
        Global,
        Module
    }
}
